<?php
$panelSettings = Zend_Json::decode($this->panel->settings);
$align = $panelSettings['align'];

// get the unit price config
$unitConfig = new RM_UnitHospitalityPricesConfig();
$personsConfigs = $unitConfig->fetchByUnit($this->unit->id)->toArray();
foreach ($personsConfigs as $configItem) {
    if ((int)$configItem['unit_value']) {
        $data[$configItem['name']] = (int)$configItem['unit_value'];
    } else {
        $data[$configItem['name']] = (int)$configItem['default_value'];
    }
}

// get the catering(board) types available
$unitprices = new RM_UnitHospitalityPrices();
$boardTypes = $unitprices->getBoardTypes($this->unit->id)->toArray();

?>
<div id="<?php echo $this->panel->getDivID() ?>">
    <div class="RM_unit_details_hospitality_container" style="text-align:<?php echo $panelSettings['align']; ?>">
        <fieldset><legend><?php echo $this->_translate->_('RM.Hospitality.Fields','HospitalityTitle');?></legend>

            <table align="center" border="0" width="100%">
                <tr>
                    <td><!-- left column -->
                        <span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'MaxOccupancy'); ?></span>
                        <span class="RM_unit_hospitality_maxpersons_value"><?php echo $data['max_occupancy']; ?></span>
                        <br/>
                        <span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'AccomTypesAvailable'); ?></span>
                        <?php
                        foreach ($boardTypes as $board){
                            if ($board['board_type']=="fb"){
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/fb_24.png" alt="'.RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'FullBoard').'" border="0"/>&nbsp;';
                            }
                            if ($board['board_type']=="hb"){
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/hb_24.png" alt="'.RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'HalfBoard').'" border="0"/>&nbsp;';
                            }
                            if ($board['board_type']=="ai"){
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/ai_24.png" alt="'.RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'AllInclusive').'" border="0"/>&nbsp;';
                            }
                            if ($board['board_type']=="bb"){
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/bb_24.png" alt="'.RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'BedandBreakfast').'" border="0"/>&nbsp;';
                            }
                            if ($board['board_type']=="sc"){
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/sc_24.png" alt="'.RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'SelfCatering').'" border="0"/>&nbsp;';
                            }
                        }
                        ?>
                    </td>
                    <td><!-- right column -->
                        <span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'CombinationOf'); ?></span>
                        <br/>
                        <table align="left" border="0">
                            <tr>
                                <td align="center">
                                    <?php
                                    for ($i = 1; $i <= (int)$data['max_adults']; $i++) {
                                        echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/adult_small.png" alt="Maximum Adults ' . $data['max_adults'] . '" border="0"/>';
                                    }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('User.Hospitality.Main', 'Adults'); ?>
                                </td>
                            </tr>
                        </table>
                        <?php if ((int)$data['max_children']>0){?>
                        <table align="left" border="0">
                            <tr>
                                <td align="center">
                                    <?php
                                    for ($i = 1; $i <= (int)$data['max_children']; $i++) {
                                        echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/child_small.png" alt="Maximum Children ' . $data['max_children'] . '" border="0"/>';
                                    }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('User.Hospitality.Main', 'Children'); ?>
                                </td>
                            </tr>
                        </table>
                        <?php }
                        if ((int)$data['max_infants']>0){
                        ?>
                       <table align="left" border="0">
                            <tr>
                                <td align="center">
                                    <?php
                                    for ($i = 1; $i <= (int)$data['max_infants']; $i++) {
                                            echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/infant_small.png" alt="Maximum Infants ' . $data['max_infants'] . '" border="0"/>';
                                    }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('User.Hospitality.Main', 'Infants'); ?>
                                </td>
                            </tr>
                        </table>
                        <?php } ?>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
</div>